<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <title>动态简单模式</title>
    <link href="/kissy/build/css/dpl/base.css" rel="stylesheet"/>
    <link href="../assets/default.css" rel="stylesheet"/>
    <style>
        .ks-combobox-focused .ks-combobox-placeholder {
            visibility: hidden;
        }
    </style>
</head>
<body>
<h1>全新产生新节点</h1>

<div style="margin:10px auto; width:800px;text-align: center" id="newNew">
    <h2>
        dynamic
    </h2>
</div>
<script src="/kissy/build/seed-debug.js"></script>
<script src="/kissy/src/package.js"></script>
<script>
    KISSY.use("combobox,util", function (S, ComboBox, util) {
        /*
         remote dataSource
         */
        (function () {
            var basicComboBox = new ComboBox({
                render: "#newNew",
                placeholder: 'input number!',
                hasTrigger: false,
                width: 400,
                dataSource: new ComboBox.RemoteDataSource({
                    xhrCfg: {
                        url: './interface2.jss',
                        dataType: 'json'
                    },
                    paramName: "start",
                    parse: function (inputVal, d) {
                        return d.result;
                    }
                }),
                maxItemCount: 10,
                format: function (query, data) {
                    var ret = [];
                    for (var i = 0; i < data.length; i++) {
                        ret[i] = {
                            content: (data[i] + "")
                                    .replace(new RegExp(util.escapeRegExp(query), "g"),
                                    "<b>$&</b>"),
                            disabled: (i % 2 ? true : false)
                        };
                    }
                    return ret;
                }
            });
            basicComboBox.render();

            basicComboBox.on("click", function (e) {
                var item = e.target;
                S.log(item.get("value") + "\n" + item.get("content") +
                        "\n" + item.get('textContent'));
            });
        })();
    });
</script>
</body>
</html>